def is_prime(num):
    if num < 2:
        return False
    for i in range(2, int(num**0.5) + 1):
        if num % i == 0:
            return False
    return True

def words_to_number(wordes):
    b = {
        'zero': 0, 'one': 1, 'two': 2, 'three': 3, 'four': 4,
        'five': 5, 'six': 6, 'seven': 7, 'eight': 8, 'nine': 9
    }
    num_str = ''.join([str(b[word]) for word in wordes.split()])
    
    if not num_str.isdigit() or len(num_str) != 3:
        return "Wrong input"
    
    num = int(num_str)
    return num

def find_nearest_prime(num):
    if is_prime(num):
        return num
    
    low = num - 1
    up = num + 1
    while True:
        if is_prime(low):
            return low
        if is_prime(up):
            return up
        low -= 1
        up += 1

wordes = input() 
num = words_to_number(wordes)
if num == "Wrong input":
    print(num)
else:
    resultes = find_nearest_prime(num)
    print(resultes)
